<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:f="http://java.sun.com/jsf/core"
                template="./default_template.xhtml">
<f:metadata>  
        <f:viewParam name="id" value="#{compteMBean.id}"/>  
</f:metadata>
    <ui:define name="content">
        <f:view>
            <f:event type="preRenderView" listener="#{compteMBean.loadCompte(event)}"/>
            <h:form>
                <h3><h:outputText value="Mettre à jour le compte de #{compteMBean.details.proprietaire}"/></h3>
                <h:panelGrid columns="2">
                    <h:outputLabel value="Solde:" for="solde" />
                    <h:inputText id="solde" value="#{compteMBean.details.solde}" title="Solde" />
                    <h:outputLabel value="Proprietaire:" for="proprietaire" />
                    <h:inputText id="proprietaire" value="#{compteMBean.details.proprietaire}" title="Proprietaire" />
                    <h:commandButton id="back" value="Back" action="#{compteMBean.list}"/>
                    <h:commandButton id="delete" value="Supprimer" action="#{compteMBean.delete}"/>  
                    <h:commandButton id="update" value="Update" action="#{compteMBean.update}"/>  
                </h:panelGrid>
            </h:form>
            
            <h:form>
                <h4><h:outputText value="Les Opérations"/></h4>
                <h:dataTable value="#{compteMBean.details.operations}" var="item">
                    <h:column>
                        <f:facet name="header">
                            <h:outputText value="Description"/>
                        </f:facet>
                        <h:outputText value="#{item.description}"/>
                    </h:column>
                    <h:column>
                        <f:facet name="header">
                            <h:outputText value="DateOperation"/>
                        </f:facet>
                        <h:outputText value="#{item.dateOperation}">
                            <f:convertDateTime pattern="MM/dd/yyyy" />
                        </h:outputText>
                    </h:column>
                    <h:column>
                        <f:facet name="header">
                            <h:outputText value="Montant"/>
                        </f:facet>
                        <h:outputText   style="color: red" value="#{item.montant}" rendered="#{-item.montant > 0}"  />
                        <h:outputText   style="color: green" value="#{item.montant}" rendered="#{item.montant > 0}"  />
                        
                    </h:column>
                </h:dataTable>
            </h:form>

        </f:view>
    </ui:define>

</ui:composition>
